package com.simon.hse.activity.safe.jobticket.breakage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.activity.SignActivity;
import com.simon.hse.activity.safe.safework.ApprovalCancelWorkPermitActivity;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

/**
 * 断路作业许可证
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_breakage_details)
public class BreakageDetailsActivity extends BaseActivity {
    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;
    @ViewInject(R.id.tv_train_record_cancel)
    TextView tv_cancel;
    @ViewInject(R.id.tv_train_record_confirm)
    TextView tv_confirm;
    @ViewInject(R.id.ll_zyfzr_2)
    LinearLayout llZyfzr2;
    @ViewInject(R.id.ll_qxtcr)
    LinearLayout llQxtcr;
    @ViewInject(R.id.ll_qxspr)
    LinearLayout llQxspr;
    String from = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        from = getIntent().getStringExtra("from");
        mTv_common_title.setText("断路作业许可证");
        initData();
    }

    @Event(value = {R.id.iv_common_left, R.id.tv_train_record_cancel, R.id.tv_train_record_confirm})
    private void back(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
                break;
            case R.id.tv_train_record_cancel:
                finish();
                break;
            case R.id.tv_train_record_confirm:
                switch (from) {
                    case "effective":
                        //有效
                        startActivity(new Intent(BreakageDetailsActivity.this, ApprovalCancelWorkPermitActivity.class).putExtra("from", "commonlyEffective"));
                        break;
                    case "temporaryStorage":
                        //暂存
                        break;
                    case "pendingConfirmed":
                        //待确认
                        finish();
                        break;
                    case "pendingApproval":
                        //待审批
                        finish();
                        break;
                    case "overdue":
                        //超期
                        startActivity(new Intent(BreakageDetailsActivity.this, ApprovalCancelWorkPermitActivity.class).putExtra("from", "commonlyOverdue"));
                        break;
                    case "close":
                        //关闭
                        finish();
                        break;
                    case "cancel":
                        finish();
                        //取消
                        break;
                    case "approval":
                        //审批
                        startActivity(new Intent(BreakageDetailsActivity.this, SignActivity.class));
                        break;
                    case "cancelApproval":
                        //取消审批
                        startActivity(new Intent(BreakageDetailsActivity.this, ApprovalCancelWorkPermitActivity.class).putExtra("from", "commonlyCancelApproval"));
                        break;
                    case "cancelQuery":
                        //取消查询
                        startActivity(new Intent(BreakageDetailsActivity.this, ApprovalCancelWorkPermitActivity.class).putExtra("from", "commonlyCancelQuery"));
                        break;
                }
                break;
        }
    }

    private void initData() {
        switch (from) {
            case "effective":
                //有效
                break;
            case "temporaryStorage":
                //暂存
                break;
            case "pendingConfirmed":
                //待确认
                tv_cancel.setVisibility(View.GONE);
                tv_confirm.setText("提交");
                break;
            case "pendingApproval":
                //待审批
                tv_cancel.setVisibility(View.GONE);
                tv_confirm.setText("返回");
                break;
            case "overdue":
                //超期
                tv_cancel.setVisibility(View.GONE);
                break;
            case "close":
                //关闭
                tv_cancel.setVisibility(View.GONE);
                llZyfzr2.setVisibility(View.VISIBLE);
                tv_confirm.setText("返回");
                break;
            case "cancel":
                //取消
                tv_cancel.setVisibility(View.GONE);
                llQxtcr.setVisibility(View.VISIBLE);
                llQxspr.setVisibility(View.VISIBLE);
                tv_confirm.setText("返回");
                break;
            case "approval":
                //审批
                tv_confirm.setText("同意并签字");
                break;
            case "cancelApproval":
                //取消审批
                llQxtcr.setVisibility(View.VISIBLE);
                tv_confirm.setText("同意");
                break;
            case "cancelQuery":
                //取消查询
                tv_confirm.setText("申请取消");
                break;
        }
    }
}
